<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="/WEB-INF/c.tld" prefix="c" %>
<%@ page import="dto.*" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'showlist.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">  
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
    <style type="text/css">
    table{position:absolute;left:320px;width:600px;}
    .input{height:36px;}
    .put{width:30px;height:20px;}
    </style>
  </head>
  
  <body background="img/3.jpg">
    <form action="" name="form1" method="post">
      <table border="2" bordercolor="pink">
        <tr>
          <td align="center">
           <img alt="用户头像" src="<%=basePath %>${user.url }" id="img" width="80" height="100"><br/>
          </td>
          <td align="center" colspan="5" class="input">
            <font size="4" color="red">用户名:</font> 
            <i><font color="purple">${user.userName }</font></i>          
            <font size="4" color="red"> 当前在线人数:</font>          
            <a href="<%=basePath %>stuJsp/showOnlineName.jsp">${count } 人</a>
            <a href="welcom.jsp"> 返回主页面</a>
            <a href="login.jsp">[安全退出]</a><br/>
            <hr/>
            <font size="6" color="red">学生基本信息</font>
          </td>
        </tr>
        <tr>
          <td align="center">
            <input type="checkbox" name="all" value="" onclick="getAll();"/>
          </td>
          <td align="center" class="input">
            <font size="4" color="red">学生ID</font>
          </td>
          <td align="center" class="input">
            <font size="4" color="red">学生姓名</font>
          </td>
          <td align="center" class="input">
            <font size="4" color="red">学生性别</font>
          </td>
          <td align="center" class="input">
            <font size="4" color="red">出生年月</font>
          </td>
           <td align="center">
            <font size="4" color="red">操作</font>
          </td>
        </tr>
        <c:forEach var="student" items="${list}">
        <tr>
           <td align="center">
            <input type="checkbox" name="one" value="${student.stuId}"/>
          </td>
          <td align="center" class="input">
            ${student.stuId}
          </td>
          <td align="center" class="input">
            ${student.stuName}
          </td>
          <td align="center" class="input">
            ${student.stuSex}
          </td>
          <td align="center" class="input">
            ${student.stuBirth}
          </td>
           <td align="center">
            <a href="doFindByIdServlet?id=${student.stuId}">修改</a>
          </td>
        </tr>
        </c:forEach>
        <tr>
          <td align="center" colspan="2">
            <input type="button" name="but1" value="新增" onclick="window.location='stuJsp/add.jsp'"/>
            <input type="button" name="but2" value="删除" onclick="chek();"/>
          </td>
          <td align="center" colspan="4">
            <a href="doShowList?currentpage=1">首页</a>
            <a href="doShowList?currentpage=${currentpage-1 }">上一页</a>
            <a href="doShowList?currentpage=${currentpage+1 }">下一页</a>
            <a href="doShowList?currentpage=${lastpage}">尾页</a>
          </td>
        </tr>
        <tr>
          <td align="center" colspan="4">
                           当前第 ${currentpage }  页
                           转至第 <input type="text" class="put" name="currentpage" value="${currentpage }"/>页
          <input type="button" class="put" name="go" value="GO" onclick="examine();"/>
                           共  ${lastpage }  页
          </td>
          <td align="center" colspan="2">
          <a href="stuJsp/upload.jsp">上传资源</a>
          <a href="FindFileServlet">下载资源</a>
          </td>
        </tr>
      </table>
    </form>
  </body>
  <script type="text/javascript">
  function $(id){
	  return document.getElementById(id);
  }
  function getAll(){
	  var allObj=document.getElementById("all");
	  var ones=document.getElementsByName("one");
	  for(var i=0;i<ones.length;i++){
		  if(allObj.checked){
			  ones[i].checked=true;
		  }else{
			  ones[i].checked=false;
		  }
	  }
  }
  function chek(){
	  var form=document.getElementById("form1");
	  var ones=document.getElementsByName("one");
	  var n=0;
	  for(var i=0;i<ones.length;i++){
		  if(ones[i].checked){
			  n++;
		  }
	  }
	  if(n==0){
		  alert("请勾选!");
	  }else{
		  form.action="doDeleteServlet";
		  form.submit();
	  }
  }
  function examine(){
	  var topage=document.getElementById("currentpage").value;
	  var form=document.getElementById("form1");
	  if(topage.match(/[0-9]*/)==topage&&topage!=""){
		  form.action="doShowList";
		  form.submit();
	  }else{
		  alert("必须为整型数字!");
	  }
  }
  </script>
</html>
